package com.bdc.activity;

import com.bdc.R;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;

public class MainTabsActivity extends TabActivity implements OnCheckedChangeListener{
	
	private TabHost tabHost ;

	@Override
	public void onCheckedChanged(CompoundButton button, boolean isChecked) {
		if(!isChecked)return ;
		
		this.tabHost.setCurrentTabByTag((String)button.getTag()) ;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.main_tabs) ;
		
		this.tabHost = getTabHost() ;
		TabHost.TabSpec tabSpec ;
		Intent intent ;
		
		intent = new Intent().setClass(this, MemorizeActivity.class) ;
		tabSpec = tabHost.newTabSpec("memorize").setIndicator("").setContent(intent) ;
		tabHost.addTab(tabSpec) ;
		
		intent = new Intent().setClass(this, VocabularyActivity.class) ;
		tabSpec = tabHost.newTabSpec("vocabulary").setIndicator("").setContent(intent) ;
		tabHost.addTab(tabSpec) ;
		
		tabHost.setCurrentTab(0) ;
		
		
		RadioGroup r = (RadioGroup)findViewById(R.id.main_radio);
		RadioButton memorizeButton = (RadioButton)r.findViewWithTag("memorize") ;
		memorizeButton.setOnCheckedChangeListener(this) ;
		RadioButton vocabularyButton = (RadioButton)r.findViewWithTag("vocabulary") ;
		vocabularyButton.setOnCheckedChangeListener(this) ;
	}

	
	
}
